﻿package  Classes{
	
public class Movement {

	private var start:Coordinate = new Coordinate(0);
	private var end:Coordinate = new Coordinate(0);
	private var value:int; // The evaluation value of this movement

	/**
	 * @param start
	 * @param end
	 */
	public function Movement(start:Coordinate, end:Coordinate) {
		this.start = start;
		this.end = end;
	}

	public function MovementXY(x0:int,y0:int,x:int,y:int) {
		if(start==null) {
			this.start = new Coordinate(x0+y0*100);
			this.end = new Coordinate(x+ y*100);
		}
		else {
			start.CoordinateXY(x0,y0);
			end.CoordinateXY(x,y);
		}
	}
	
	public function toInteger():int 
	{
		return start.value + end.value*10000;
	}
	
	public function parseMoveInteger(mv:int) {
		var ei:int = mv/10000;
		var si:int = mv%10000;
		start.CoordinateValue(si);
		end.CoordinateValue(ei);
	}

	/**
	 * @return the start
	 */
	public function  getStart():Coordinate {
		return start;
	}

	/**
	 * @param start
	 *            the start to set
	 */
	public function  setStart(start:Coordinate) {
		this.start = start;
	}

	/**
	 * @return the end
	 */
	public function getEnd():Coordinate {
		return end;
	}

	/**
	 * @param end
	 *            the end to set
	 */
	public function setEnd(end:Coordinate) {
		this.end = end;
	}

	public function startx():int {
		return start.x;
	}

	public function starty():int {
		return start.y;
	}

	public function endx():int {
		return end.x;
	}

	public function endy():int {
		return end.y;
	}

	/**
	 * @return the value
	 */
	public function getValue():int {
		return value;
	}

	/**
	 * @param value
	 *            the value to set
	 */
	public function setValue( value:int):void {
		this.value = value;
	}

	/**
	 * @see java.lang.Comparable#compareTo(java.lang.Object)
	 */
	public function compareTo(o:Movement):int {
		var m:Movement = o;
		return m.getValue() - this.value;
	}

}//end class
}//end package
